import React, {Component} from 'react'
import '../sass/Message'

export default class Message extends Component {
  constructor() {
    super()
  }

  _hideMessage = () => {
    this.props.hideMessage()
  }

  componentDidMount() {
    setTimeout(this.props.hideMessage, 2000)
  }

  render() {
    const {message} = this.props

    if (message) {
      return (
          <div className="message-wrapper" onClick={this._hideMessage.bind(this)}>
              <div className="message">
                  {message}
              </div>
          </div>
      )
    } else {
      return (
        <div></div>
      )
    }
  }
}
